import { CHANGE_CID, CHANNEL_LIST } from '../constants/channels'

export default function channels(
  state = {
    currentId: '', // 当前 ID
    list: [], // 频道数据
  },
  action
) {
  switch (action.type) {
    case CHANNEL_LIST:
      return {
        ...state,
        currentId: action.id,
        list: action.payload,
      }
    case CHANGE_CID:
      return {
        ...state,
        currentId: action.cid,
      }
    default:
      return state
  }
}
